package com.dzl.movie;

import com.alibaba.fastjson.JSONObject;
import com.alipay.api.domain.QueryUserChargeInstAndAreaInfo;
import com.dzl.base.controller.BaseController;
import com.dzl.moive.pojo.query.WelfareMovieOrderListQuery;
import com.dzl.moive.pojo.vo.WelfareMovieOrderListVo;
import com.dzl.moive.service.WelfareMovieOrderService;
import com.dzl.util.JsonResult;
import com.dzl.util.PageUtils;
import com.github.pagehelper.PageInfo;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 电影订单流水控制层
 * @date 2021/11/4 14:03
 * @author caobucao
 */
@RestController
@RequestMapping("/welfareMovieOrderFlow")
public class WelfareMovieOrderFlowController extends BaseController {

    @Resource
    private WelfareMovieOrderService welfareMovieOrderService;

    /**
     * 顶部状态栏数量
     * @date 2021/11/5 10:37
     * @author caobucao
     * @param query 查询条件
     * @return com.dzl.util.JsonResult<java.util.List<java.lang.Integer>>
     */
    @GetMapping("/getMovieOrderFlowCountState")
    public JsonResult<List<Integer>> getMovieOrderFlowCountState(WelfareMovieOrderListQuery query) {
        query.setEnterpriseId(getAdminInfo().getEnterpriseId());
        return JsonResult.success(welfareMovieOrderService.getMovieOrderCount(query));
    }

    /**
     * 分页查询电影订单流水
     * @date 2021/11/4 15:10
     * @author caobucao
     * @param query 查询条件
     * @return com.dzl.util.PageUtils<com.dzl.moive.pojo.vo.WelfareMovieOrderFlowVo>
     */
    @GetMapping("/getMovieOrderFlowVoPage")
    public PageUtils<WelfareMovieOrderListVo> getMovieOrderFlowVoPage(WelfareMovieOrderListQuery query) {
        query.setEnterpriseId(getAdminInfo().getEnterpriseId());
        PageInfo<WelfareMovieOrderListVo> pageInfo = welfareMovieOrderService.getMovieOrderVoPage(query);
        return new PageUtils<>(pageInfo);
    }

    /**
     * 全部导出
     * @date 2021/11/4 15:10
     * @author caobucao
     * @param query 查询条件
     * @return com.dzl.util.PageUtils<com.dzl.moive.pojo.vo.WelfareMovieOrderFlowVo>
     */
    @GetMapping("/exportAllFlow")
    public void exportAllFlow(WelfareMovieOrderListQuery query, HttpServletResponse res, HttpServletRequest req) {
        query.setEnterpriseId(getAdminInfo().getEnterpriseId());
        welfareMovieOrderService.exportOrderFlowList(query, 1,res, req);
    }

    /**
     * 导出选中电影订单流水
     * @date 2021/11/5 10:46
     * @author caobucao
     * @param jsonObject 选中ids
     * @return void
     */
    @PostMapping("/exportFlowByIds")
    public void exportFlowByIds(@RequestBody JSONObject jsonObject, HttpServletResponse res, HttpServletRequest req) {
        String ids = jsonObject.getString("ids");
        WelfareMovieOrderListQuery query = new WelfareMovieOrderListQuery();
        query.setOrderIds(ids);
        welfareMovieOrderService.exportOrderFlowList(query, 1,res, req);
    }


}
